'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    /**
     * Add altering commands here.
     *
     * Example:
     * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
     */

    const { INTEGER, STRING, DATE } = Sequelize;
    await queryInterface.createTable("sys_dept", {

      dept_id: {
        type: INTEGER,
        comment: "部门id",
        primaryKey: true,
        autoIncrement: true
      },
      parent_id: {
        type: INTEGER,
        comment: "父部门",
        defaultValue: 0
      },
      ancestors: {
        type: STRING(50),
        comment: "祖级列表"
      },
      dept_name: {
        type: STRING(30),
        comment: "部门名称"
      },
      order_num: {
        type: INTEGER(4),
        comment: "显示顺序"
      },
      leader: {
        type: STRING(20),
        comment: "负责人"
      },
      phone: {
        type: STRING(11),
        comment: "联系电话"
      },
      email: {
        type: STRING(50),
        comment: "邮箱"
      },
      status: {
        type: STRING(1),
        comment: "部门状态（0正常 1停用）"
      },
      create_by:{
        type:STRING(64),
        comment:"创建者"
      },
      created_at:{
        type:DATE,
        comment:"创建时间",
      },
      updated_at:{
        type:DATE,
        comment:"更新时间",
      },
      deleted_at:{
        type:DATE,
        comment:"删除时间",
      }
    });
  },

  down: async (queryInterface, Sequelize) => {
    /**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('users');
     */
    await queryInterface.dropTable("sys_dept");
  }
};
